<include file="Public/header"/>
<include file="Public/menu"/>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            商品
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 商品管理</a></li>
            <li class="active">商品分类</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <form action="/Qgs/rbac/roleAddMenu/id/3" method="post">
                        <div class="box-header">


                            <div class="btn-group pull-right" style="margin-right: 10px">
                                <a href="{:U('Qgs/StoreCat/add')}" class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;新增</a>
                            </div>

                        </div>
                        <!-- /.box-header -->
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tbody>
                                <tr>
                                    <th></th>
                                    <th>商品分类</th>
                                    <th>操作</th>
                                </tr>
                                <input type="hidden" name="id" value="3">
                                <?php foreach($parent as $p){ ?>
                                <tr>
                                    <td></td>
                                    <td>
                                        <?php echo $p['cat_name'];?>
                                    </td>
                                    <td>
                                        <a href="/Qgs/storeCat/edit/id/<?php echo $p['store_cat_id'];?>"><i class="fa">修改</i></a>
                                        <a href="/Qgs/storeCat/delete/id/<?php echo $p['store_cat_id'];?>"><i class="fa">删除</i></a>
                                    </td>
                                </tr>
                                <?php foreach($second as $s){ if ($s['parent_id'] == $p['store_cat_id']) { ?>
                                <tr>
                                    <td></td>
                                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $s['cat_name'];?></td>
                                    <td>
                                        <a href="/Qgs/storeCat/edit/id/<?php echo $s['store_cat_id'];?>"><i class="fa">修改</i></a>
                                        <a href="/Qgs/storeCat/delete/id/<?php echo $s['store_cat_id'];?>"><i class="fa">删除</i></a>
                                    </td>
                                </tr>

                                <?php foreach($three as $t){ if ($t['parent_id'] == $s['store_cat_id']) { ?>
                                <tr>
                                    <td></td>
                                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $t['cat_name'];?></td>
                                    <td>
                                        <a href="/Qgs/storeCat/edit/id/<?php echo $t['store_cat_id'];?>"><i class="fa">修改</i></a>
                                        <a href="/Qgs/storeCat/delete/id/<?php echo $t['store_cat_id'];?>"><i class="fa">删除</i></a>
                                    </td>
                                </tr>

                                <?php }}  ?>

                                <?php }}  ?>
                                <?php } ?>

                                </tbody>
                            </table>
                        </div>

                    </form>
                </div>
            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>

<script data-exec-on-popstate>

    $(function () {

        $('.grid-select-all').change(function() {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.batch-delete').on('click', function() {
            var selected = [];
            $('.grid-item:checked').each(function(){
                selected.push($(this).data('id'));
            });

            if (selected.length == 0) {
                return;
            }

            if(confirm("Are you sure to delete this item ?")) {
                $.post('/Qgs/auth/roles/' + selected.join(), {_method:'delete','_token':'ALpaP7hXZ6s2dnAdE02Z6mUSHPt8RkYbcDRp6rpw'}, function(data){
                    $.pjax.reload('#pjax-container');
                    noty({
                        text: "<strong>Succeeded!</strong>",
                        type:'success',
                        timeout: 1000
                    });
                });
            }
        });
    });
</script>